﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace BesAsm.Stormwater.Swmm5Results
{
  public class CatchmentVariables : ResultVariablesBase, IName
  {
    public ResultVariable Rainfall = new ResultVariable("Rainfall", 0);
    public ResultVariable SnowDepth = new ResultVariable("SnowDepth", 4);
    public ResultVariable EvaporationAndInfiltration = new ResultVariable("EvaporationAndInfiltration", 8);
    public ResultVariable RunoffRate = new ResultVariable("RunoffRate", 12);
    public ResultVariable GroundwaterOutflowRate = new ResultVariable("GroundwaterOutflowRate", 16);
    public ResultVariable GroundwaterWaterTable = new ResultVariable("GroundwaterWaterTable", 20);   

    public float Area { get; internal set; }
    
    public CatchmentVariables(string name, OutputFileReader reader)
    {
      _reader = reader;
      _name = name;
      _variables.Add(Rainfall);
      _variables.Add(SnowDepth);
      _variables.Add(EvaporationAndInfiltration);
      _variables.Add(RunoffRate);
      _variables.Add(GroundwaterOutflowRate);
      _variables.Add(GroundwaterWaterTable);
    }

    protected override int GetElementPosition()
    {
      return _reader.CatchmentPosition[Name];
    }

    public void LoadRainfall(bool close)
    {
      Rainfall.SetData(
        LoadResult(Rainfall.Position, close));
      Rainfall.IsLoaded = true;
    }
    public void LoadSnowDepth(bool close)
    {
      SnowDepth.SetData(
        LoadResult(SnowDepth.Position, close));
      SnowDepth.IsLoaded = true;
    }
    public void LoadEvaporationAndInfiltration(bool close)
    {
      EvaporationAndInfiltration.SetData(
        LoadResult(EvaporationAndInfiltration.Position, close));
      EvaporationAndInfiltration.IsLoaded = true;
    }
    public void LoadRunoffRate(bool close)
    {
      RunoffRate.SetData(
        LoadResult(RunoffRate.Position, close));
      RunoffRate.IsLoaded = true;
    }
    public void LoadGroundwaterOutflowRate(bool close)
    {
      GroundwaterOutflowRate.SetData(
        LoadResult(GroundwaterOutflowRate.Position, close));
      GroundwaterOutflowRate.IsLoaded = true;
    }
    public void LoadGroundwaterWatertables(bool close)
    {
      GroundwaterWaterTable.SetData(
        LoadResult(GroundwaterWaterTable.Position, close));
      GroundwaterWaterTable.IsLoaded = true;
    }
    
  }

}
